package br.com.condominio.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@SequenceGenerator(name = "funcao_func_codigo_seq", sequenceName = "funcao_func_codigo_seq", allocationSize = 1)
public class Funcao implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer funcCodigo;
	private String funcDescricao;
	private Set<Responsavel> responsavels = new HashSet<Responsavel>(0);

	public Funcao() {
	}

	public Funcao(Integer funcCodigo, String funcDescricao) {
		this.funcCodigo = funcCodigo;
		this.funcDescricao = funcDescricao;
	}

	public Funcao(Integer funcCodigo, String funcDescricao,
			Set<Responsavel> responsavels) {
		this.funcCodigo = funcCodigo;
		this.funcDescricao = funcDescricao;
		this.responsavels = responsavels;
	}

	@Id
	@Column(name = "func_codigo", unique = true, nullable = false, precision = 131089, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "funcao_func_codigo_seq")
	public Integer getFuncCodigo() {
		return this.funcCodigo;
	}

	public void setFuncCodigo(Integer funcCodigo) {
		this.funcCodigo = funcCodigo;
	}

	@Column(name = "func_descricao", nullable = false)
	public String getFuncDescricao() {
		return this.funcDescricao;
	}

	public void setFuncDescricao(String funcDescricao) {
		this.funcDescricao = funcDescricao;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "funcao")
	public Set<Responsavel> getResponsavels() {
		if(this.responsavels == null)
			responsavels = new HashSet<Responsavel>(0);
		return this.responsavels;
	}

	public void setResponsavels(Set<Responsavel> responsavels) {
		this.responsavels = responsavels;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((funcCodigo == null) ? 0 : funcCodigo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Funcao other = (Funcao) obj;
		if (funcCodigo == null) {
			if (other.funcCodigo != null)
				return false;
		} else if (!funcCodigo.equals(other.funcCodigo))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Funcao [funcCodigo=" + funcCodigo + ", funcDescricao="
				+ funcDescricao + "]";
	}
	
	

}
